package com.eryos.gwt.estate.client.factory.impl;

import com.eryos.gwt.estate.client.factory.ClientFactory;
import com.eryos.gwt.estate.client.i18n.Messages;
import com.eryos.gwt.estate.client.view.ErrorView;
import com.eryos.gwt.estate.client.view.HomeView;
import com.eryos.gwt.estate.client.view.impl.ErrorViewImpl;
import com.eryos.gwt.estate.client.view.impl.HomeViewImpl;
import com.eryos.gwt.estate.core.service.ConfigService;
import com.eryos.gwt.estate.core.service.ConfigServiceAsync;
import com.eryos.gwt.estate.core.service.GreetingService;
import com.eryos.gwt.estate.core.service.GreetingServiceAsync;
import com.eryos.gwt.estate.moduleA.client.view.ModuleAView;
import com.eryos.gwt.estate.moduleA.client.view.impl.ModuleAViewImpl;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.SimpleEventBus;
import com.google.gwt.place.shared.PlaceController;
import com.google.web.bindery.event.shared.EventBus;

/**
 * 
 * @author combeol
 * @version $Revision$
 */
public class ClientFactoryImpl implements ClientFactory {

    // Could be injected via GIN
    private static final EventBus eventBus = new SimpleEventBus();
    private static final PlaceController placeController = new PlaceController(eventBus);

    /** Create a remote service proxy to talk to the server-side Greeting service. */
    private final GreetingServiceAsync greetingService = GWT.create(GreetingService.class);

    /** Configuration Service. */
    private final ConfigServiceAsync configService = GWT.create(ConfigService.class);

    /** I18n interface for labels. */
    private final Messages messages = GWT.create(Messages.class);

    /************ All Views ************/
    private static final HomeView homeView = new HomeViewImpl();
    private static final ErrorView errorView = new ErrorViewImpl();
    private static final ModuleAView moduleAView = new ModuleAViewImpl();

    /**
     * {@inheritDoc}
     */
    @Override
    public EventBus getEventBus() {
        return eventBus;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public PlaceController getPlaceController() {
        return placeController;
    }

    /************ All Views Methods ************/

    /**
     * {@inheritDoc}
     */
    @Override
    public HomeView getHomeView() {
        return homeView;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public ErrorView getErrorView() {
        return errorView;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public GreetingServiceAsync getGreetingService() {
        return greetingService;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public ConfigServiceAsync getConfigService() {
        return configService;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Messages getMessages() {
        return messages;
    }

    @Override
    public ModuleAView getModuleAView() {
        return moduleAView;
    }

}
